package com.itheima.api.hashmap.demo02;

import java.util.HashMap;

public class HashMapDemo01 {

    public static void main(String[] args) {

        Student s1 = new Student("张三", 18);
        Student s2 = new Student("李四", 20);
        Student s3 = new Student("王五", 23);
        Student s4 = new Student("王五", 23);

        HashMap<Student, String> hashMap = new HashMap<Student, String>();

        hashMap.put(s1, "上海");
        hashMap.put(s2, "北京");
        hashMap.put(s3, "西安");
        hashMap.put(s4, "香港");

        hashMap.forEach((key, value) -> {
            String name = key.getName();
            int age = key.getAge();
            System.out.println(name + "---" + age + "---" + value);
        });

    }

}
